<template>
	<view v-show="!pageLoading">
		<PersonalPlanDetail :senditem="senditem">
			<template #toolbar>
				<view class="mycss-flex-start-clumncenter-nowarp uni-pa-3" style="background-color: #FFFFFF;">
					<view class="mycss-ma-5">
						<u-button type="primary" size="mini" @click="goPre()">上一位</u-button>
					</view>
					<view>
						<u-button type="primary" size="mini" @click="goCurrent()">本位</u-button>
					</view>
					<view>
						<u-button type="primary" size="mini" @click="goNext()">下一位</u-button>
					</view>
				</view>
				<view class="mycss-ma-5" style="background-color: #FFFFFF;">
					<text>
						[{{senditem?senditem.name:''}}][排位:{{index+1}}]
					</text>
				</view>
			</template>
		</PersonalPlanDetail>
	</view>
</template>
<script setup>
	import {
		onLoad,
		onReady
	} from "@dcloudio/uni-app"
	import MyLoading from "@/components/my-loading/my-loading"
	import PersonalPlanDetail from "@/pages/personal-plan/components/personal-plan-detail/personal-plan-detail.vue"
	import {ref,reactive} from "vue"
	let tableData=null;
	const myitem=ref(null);
	const senditem=ref(null);
	const index=ref(0);
	const myindex=ref(0)
	const pageLoading = ref(true)
	onReady(() => {
		pageLoading.value = false;
	})
	onLoad(()=>{
		uni.$once("allplansend",(obj,item,i)=>{
			console.log(obj,item,i);
			tableData=obj;
			myitem.value=item;
			senditem.value=item;
			index.value=i;
			myindex.value=i;
		})
	})
	function goPre(){
		if(index.value>0){
			index.value--;
			senditem.value=tableData[index.value]
		}
	}
	function goCurrent(){
		senditem.value=myitem.value;
		index.value=myindex.value;
	}
	function goNext(){
		if(index.value<tableData.length-1){
			index.value++;
			senditem.value=tableData[index.value]
		}
	}
</script>